﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace _95定义一个使用文件流复制文件的方法
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            //路径
            string path = @"D:\Apeixun\ShiXun\MyHomeWork\weekend-homework\20201211\贺佳良\1\test.txt";
            //创建文件读和写的文件流
            using (FileStream fs = File.OpenRead(path), fswrite = File.Create(@"D:\Apeixun\ShiXun\MyHomeWork\weekend-homework\20201211\贺佳良\1\test1.txt"))
            {
                //缓冲区1kb
                byte[] array = new byte[1024];
                while (true)
                {
                    //读取
                    int length = fs.Read(array, 0, array.Length);
                    if (length == 0)
                    {
                        break;
                    }
                    //写入
                    fswrite.Write(array, 0, array.Length);
                }
                Console.WriteLine("文件复制完成！");
                ;
            }
        }
    }
}